package com.c.ctgproject.ui.sell.parts

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.c.ctgproject.base.BaseViewModel
import com.c.ctgproject.http.ApiMethods
import com.c.ctgproject.utils.awaitSync
import com.c.ctgproject.utils.launch
import com.c.ctgproject.utils.userToken
import okhttp3.RequestBody

class PartsSellViewModel : BaseViewModel() {
    private val mSubmitResult = MutableLiveData<String>()
    val submitResult: LiveData<String> get() = mSubmitResult

    //提交需要销售的配件
    fun submitParts(body: RequestBody) {
        launch({
            mSubmitResult.value= ApiMethods.getApiService().sellAccessories(userToken, body).awaitSync()
        }, {
            mError.value = it.message.toString()
        })
    }
}